<template>
  <div class="innerPage" v-if="page">
    <div class="inner-img">
      <div class="img-bg" v-if="VideoIndexOf(Contentlist.collection.cover || Contentlist.antsCollectionBlindBox.image)"
        :style="'background-image:url(' + Contentlist.collection.cover || Contentlist.antsCollectionBlindBox.image + ') '">
        <div class="img-status" v-if="!paytype">
          <img src="@/assets/image/status.png" alt="">
        </div>
        <img :src="Contentlist.collection.cover || Contentlist.antsCollectionBlindBox.image" alt="">
      </div>
      <div class="videoContainer" v-else>
        <div class="img-status" v-if="!paytype">
          <img src="@/assets/image/status.png" alt="">
        </div>
        <vdeo :collection='Contentlist.collection.files || Contentlist.antsCollectionBlindBox.files' class="video" />
      </div>
    </div>
    <div class="bottom-bg"></div>
    <van-row justify="center">
      <van-col span="24" class="inner-title">
        <h1>{{ Contentlist.collection.name || Contentlist.antsCollectionBlindBox.name }}</h1>
        <h2>{{ Contentlist.userCode || Contentlist.antsCollectionBlindBox.userCode }}</h2>
      </van-col>
      <van-col>
        <p class="linercolor">{{ Contentlist.collection.userCode || Contentlist.antsCollectionBlindBox.userCode }}</p>
      </van-col>

    </van-row>
    <!-- <div>
      <van-row justify="end" class="colletion-authon">
        <van-col span="12">结束时间 : </van-col>
        <van-col span="12" class="right">
          <span>{{ Contentlist.collection.serviceProvider || Contentlist.antsCollectionBlindBox.serviceProvider
          }}</span>
        </van-col>
      </van-row>
      <van-row justify="end" class="colletion-authon">
        <van-col span="12">竞拍方 : </van-col>
        <van-col span="12" class="right">
          <span>{{ Contentlist.collection.serviceProvider || Contentlist.antsCollectionBlindBox.serviceProvider
          }}</span>
        </van-col>
      </van-row>
      <van-row justify="end" class="colletion-authon">
        <van-col span="12">当前最高价 : </van-col>
        <van-col span="12" class="right">
          <span>{{ Contentlist.collection.serviceProvider || Contentlist.antsCollectionBlindBox.serviceProvider
          }}</span>
        </van-col>
      </van-row>
      <div class="collect-info">
        规则说明
      </div>
      <div class="story">
        <p>1.每次竞价成功，竞价金额会被冻结，直到竞拍结束</p>
        <p>2.竞拍结束时，出价最高的竞价者可购得该藏品</p>
      </div>
    </div> -->
    <div class="collect-info">
      藏品信息
    </div>
    <van-row justify="end" class="colletion-authon">
      <van-col span="12">创作者</van-col>
      <van-col span="12" class="right">
        <span>{{ Contentlist.collection.serviceProvider || Contentlist.antsCollectionBlindBox.serviceProvider }}</span>
      </van-col>
    </van-row>
    <van-row justify="end" class="colletion-authon">
      <van-col span="12">发行方</van-col>
      <van-col span="12" class="right">
        <span>{{ Contentlist.collection.mechanism || Contentlist.antsCollectionBlindBox.mechanism }}</span>
      </van-col>
    </van-row>
    <van-row justify="end" class="colletion-authon">
      <van-col span="6">合约地址</van-col>
      <van-col span="18" class="right">
        <p>{{ Contentlist.assetId ? Contentlist.assetId : '未上链' }}</p>
        <img src="../../assets/image/icon/copids.png" alt="" @click="copy">
      </van-col>
    </van-row>
    <van-row justify="end" class="colletion-authon" v-if="!paytype">
      <van-col span="12">中签可购</van-col>
      <van-col span="12" class="right">
        <span>{{ Contentlist.collection.appName || Contentlist.antsCollectionBlindBox.appName }}</span>
      </van-col>
    </van-row>
    <div class="collect-info">
      藏品详情
    </div>
    <div class="story">
      <img :src="Contentlist.collection.certificatePictureUrl" alt=""
        @click="openImg(Contentlist.collection.certificatePictureUrl)">
      <div v-html="Contentlist.collection.story || Contentlist.antsCollectionBlindBox.story"></div>
    </div>
    <!-- <div class="story" v-html="Contentlist.collection.story || Contentlist.antsCollectionBlindBox.story"></div> -->
    <div class="collect-info">
      购买须知
    </div>
    <div class="story"> 数字藏品为虚拟商品，而非实物，仅限实名认证的中国大陆用户购买，数字藏品的版权由发行方或原创作者拥有，除另外取得版权拥有者书面同意外，
      用户不得将数字藏品用于任何商业用途。本商品一经售出，不支持退换。本商品源文件不支持本地下载，请勿对数字藏品进行炒作/场外交易/欺诈或以任何其他非法方式进行使用。</div>
    <!-- v-if="Contentlist.isLogUserSell == 0" -->
    <div class="fiexd-footer">
      <!-- <van-cell-group inset>
        <van-field v-model="formData.amount" type="tel" placeholder="请输入竞拍价格" />
      </van-cell-group> -->
      <div class="footer">
        <van-row justify="space-between" class="fsb">
          <van-col span="12">
            <span class="price">￥{{ Contentlist.amount || Contentlist.antsCollectionBlindBox.amount }}</span>
          </van-col>
          <van-col span="12" class="right">
            <van-button type="primary" @click="openPwd" class="buy">
              <span>立即购买</span>
            </van-button>
          </van-col>
        </van-row>
      </div>
    </div>
  </div>
  <Pwdwarp ref="PwdShow" :paydata="paydata" @updata:load="onLoad" />
</template>
<script>
import { reactive, computed, onMounted, defineComponent, onBeforeMount, ref, watch } from 'vue'
import Clipboard from 'clipboard';
import useClipboard from 'vue-clipboard3'
import { useStore } from "vuex";
import { useRouter } from "vue-router"
import { VideoIndexOf, formatPhoneNumber } from "@/utils/phone";
import Pwdwarp from "@/components/pwd.vue";
import { collectionInfo, needSynthesisList, shopping, findByBlindBox, sellgetInfo, getCollectionInfotype, orderDetail } from "@/api/public";
import { Toast, ImagePreview } from "vant";
import vueVideo from "@/components/vueVideo.vue";
import vdeo from "@/components/video.vue";
export default {
  components: {
    Pwdwarp, vueVideo, vdeo
  },
  setup(props) {
    onMounted(async () => {
      onLoad()
      await store.dispatch('user/getUserAll')

    })
    const store = useStore();
    const router = useRouter()
    const page = ref(false)
    const paytype = ref(true)
    const { toClipboard } = useClipboard()
    const Contentlist = ref({})
    const Available = ref([])
    const user_info = computed(() => {
      return store.getters.user_info
    })
    const formData = reactive({
      type: null,
      amount: 0
    })
    const onLoad = async () => {
      Toast.loading({
        message: '数据加载中...',
        forbidClick: true,
      });
      const data = { sellId: router.currentRoute.value.query.id }
      const res = router.currentRoute.value.query.type ? await orderDetail({ id: router.currentRoute.value.query.id }) : await sellgetInfo(data)
      if (res.data.success) {
        page.value = true
        Toast.clear()
        Contentlist.value = res.data.data
        console.log(res.data.data)
        paydata.value.useSellId = Contentlist.value.userCollectionSellId
      }
    }
    const paydata = ref({
      // useSellId: router.currentRoute.value.query.id,
      type: "1",
      useSellId: Contentlist.value.userCollectionSellId
    })
    const PwdShow = ref(null)
    const openPwd = async () => {
      if (!store.getters.user_info.realName) {
        router.push('/realName')
        return false
      }
      if (!store.getters.user_info.payPassword) {
        router.push('/editPwd')
        return false
      }
      PwdShow.value.pwdopen = true
    }
    const toastname = (item) => {
      Toast(item.name)
    }
    const copy = async () => {
      try {
        await toClipboard(Contentlist.value.assetId)
        Toast("复制成功")
      } catch (e) {
        console.error(e)
      }
    }

    return {
      Contentlist, Available, onLoad, copy, openPwd, PwdShow, paydata, user_info, toastname, page, VideoIndexOf, paytype, formData
    }
  }
}
</script>
<style lang="less" scoped>
.linercolor {
  font-size: 36px;
  width: fit-content;
  margin: 0px auto 20px;
  display: block;
}

.videoContainer {
  overflow: hidden;
  border-radius: 40px 40px 0px 0px;
  border: 1px solid #ffffff;

  .fullscreenVideo {
    width: 100%;
    //  width: 648px;
    height: 648px;
  }

  .img-status {
    position: absolute;
    right: 60px;
    top: 20px;

    img {
      width: 120px;
    }
  }
}

.videoContainers {
  position: relative;

  .img-status {
    position: absolute;
    right: 0px;

    img {
      width: 200px;
    }
  }

  .video {
    // width: 648px;
    // height: 648px;
    overflow: hidden;
    margin-top: 10px;

    .video {
      width: 100%;
      height: 348px;
    }
  }

  overflow: hidden;
  border-radius: 40px 40px 0px 0px;

  .fullscreenVideo {
    overflow: hidden;
    width: 100%;

    // height: 180px;
    source {
      width: 100%;
      border-radius: 40px 40px 0px 0px;
    }
  }
}

.innerPage {
  padding-bottom: 148px;

  .inner-img {
    overflow: hidden;
    width: 648px;
    height: 648px;
    background: linear-gradient(0deg, #161718, #4b4c4d);
    border: 2px solid #ffffff;
    border-radius: 80px;
    margin: 80px auto 20px;

    .img-bg {
      width: 100%;
      height: 100%;
      background-size: cover;
      // margin: 100px auto;
      position: relative;

      img {
        width: 100%;
        height: 100%;
      }

      .img-status {
        position: absolute;
        right: 0px;

        img {
          width: 200px;
        }
      }
    }
  }

  .bottom-bg {
    background: url('../../assets/image/bottom.png');
    width: 660px;
    height: 220px;
    background-size: cover;
    margin: 0px auto;
  }

  .inner-title {
    // display: flex;
    // justify-content: center;
    // align-items: center;
    // text-align: center;

    h1 {
      font-size: 46px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: #f8f8f8;
      line-height: 46px;
      margin: 0px;
      text-align: center;
    }

    h2 {
      text-align: center;
      font-size: 36px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: #F8F8F8;
      line-height: 36px;
      background: linear-gradient(-90deg, #37DC6D 0%, #34D1F9 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }
  }


  .Limit-warp {
    margin-right: 20px;

    span {
      font-size: 26px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      line-height: 48px;
    }

    span:nth-child(1) {
      color: #444442;
      font-size: 26px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      background: #f3e3bb;
      border-radius: 4px 0px 0px 4px;
      padding: 3px 12px;
    }

    span:nth-child(2) {
      padding: 3px 12px;
      background: #444442;
      border-radius: 4px;
      font-size: 26px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: #f3e3bb;
      line-height: 48px;
    }
  }

  .colletion-authon {
    padding: 0px 18px;
    font-size: 34px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #ffffff;
    line-height: 140px;
    margin: 30px 20px 0px;
    height: 140px;
    background: #282a2c;
    border: 1px solid #ffffff;
    border-bottom: 0px;
    box-shadow: 0px 2px 30px 0px rgba(0, 0, 0, 0.35);
    border-radius: 20px;

    .right {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      text-align: right;

      p {
        width: 80%;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      img {
        width: 40px;
        margin-left: 20px;
      }

      text-align: right;

      span {
        text-align: center;
        font-size: 30px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #fefefe;
        background: linear-gradient(-90deg, #37dc6d 0%, #34d1f9 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }
    }
  }

  .collect-info {
    z-index: 1;
    margin-top: 50px;
    font-size: 36px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #f8f8f8;
    margin-left: 20px;
    padding-left: 40px;
    position: relative;
  }

  .collect-info::after {
    opacity: 0.8;
    z-index: -1;
    background-size: 100% 100%;
    width: 70px;
    height: 60px;
    top: -10px;
    left: 0;
    position: absolute;
    content: '';
    background-image: url('../../assets/image/point.png');
  }

  .Available {
    background: #282a2c;
    border-radius: 20px;
    margin: 30px 20px;
    padding: 20px 10px;

    .between-warp {
      position: relative;
      overflow: hidden;

      img {
        width: 100%;
        height: 180px;
      }
    }

    .img-warp {
      margin-top: 10px;
      // padding: 30px 10px;
      overflow: hidden;
      background: linear-gradient(0deg, #161718, #4b4c4d);
      border: 2px solid #ffffff;
      border-radius: 20px;
      background: linear-gradient(0deg, #161718, #4b4c4d);
      border: 2px solid #ffffff;
      border-radius: 20px;
    }
  }

  .story {
    background: #282a2c;
    border: 1px solid #ffffff;
    box-shadow: 0px 2px 16px 0px rgba(0, 0, 0, 0.35);
    border-radius: 20px;
    margin: 30px 30px;
    padding: 60px 30px;
    font-size: 28px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #ffffff;
    line-height: 48px;
    word-break: break-word; //文本超出 自动换行

    /deep/ img {
      width: 100%;
    }

    div {
      word-break: break-word; //文本超出 自动换行
    }
  }

  .footer {
    display: flex;
    align-items: center;
    flex-flow: wrap;

    .price {
      font-size: 46px;
      font-family: Source Han Sans CN;
      font-weight: bold;
      color: #f8f8f8;
      margin-left: 50px;
    }

    .right {
      padding-right: 20px;
      text-align: right;
      display: flex;
      justify-content: flex-end;
      // &:deep(.van-button) {

      // }
      .sed {
        border: none;
        border-radius: 62px;
        width: 256px;
        height: 74px;
        background: #7d8184 !important;
        border-radius: 32px;

        span {
          display: block;
          font-size: 28px;
          font-family: Source Han Sans CN;
          font-weight: 400;
          color: #ffffff;
          line-height: 26px;
        }
      }

      .buy {
        border: none;
        background: linear-gradient(-90deg, #37dc6d, #34d1f9);
        border-radius: 62px;
        width: 256px;
        height: 74px;

        span {
          display: block;
          color: #f8f8f8;
        }
      }
    }
  }
}

&:deep(.van-popup) {
  background: #000 !important;
}

.gift-warp {
  padding-top: 50px;

  i {
    top: 20px;
    right: 20px;
    position: absolute;
    color: #fefefe;
    font-size: 60px;
  }

  img {
    display: block;
    width: 625px;
    height: 415px;
    margin: 50px auto 0px;
  }

  .box-btn {
    font-size: 32px;
    display: block;
    border: none;
    width: 448px;
    height: 80px;
    background: linear-gradient(-90deg, #37dc6d, #34d1f9);
    margin: 20px auto;
  }

  h1 {
    text-align: center;
    font-size: 48px;
    font-family: Source Han Sans CN;
    font-weight: bold;
    color: #f3e3bb;
    line-height: 42px;
    margin: 40px 0px;
  }

  width: 688px;
  height: 777px;
  background-image: url('../../assets/image/giftbg.png');
  background-size: 100% 100%;
}

&:deep(.van-cell-group) {
  margin: 56px 30px 0px;
  background: transparent;
  // min-height: 520px;
}

&:deep(.van-cell) {
  height: 100px;
  background: #282a2c;
  border: 1px solid #999;
  border-radius: 18px;
}

&:deep(.van-field__control) {
  font-size: 30px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  color: #b9c4c7;
  opacity: 0.8;
}

.fiexd-footer {
  width: 750px;
  padding: 30px 0px;
  background: #282a2c;
  position: fixed;
  bottom: 0px;
  z-index: 999;
}

.fsb {
  display: flex;
  flex-flow: nowrap;
  justify-content: space-between !important;
  align-items: center;
  width: 100%;
}
</style>